home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / File / c / LoadTo < prev    next >
Text File  |  1995-07-08  |  1KB  |  51 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    File.LoadTo.c
  12.     Author:  Copyright © 1994 Peter Gaunt
  13.     Version: 1.00 (12 Mar 1994)
  14.     Purpose: Loads a file at a given address.
  15. */
  16.  
  17. #include "kernel.h"
  18.  
  19. #include "DeskLib:Core.h"
  20. #include "DeskLib:SWI.h"
  21. #include "DeskLib:File.h"
  22. /*
  23.  * Loads a file at an address
  24.  *
  25.  * If size is not NULL then it is set to file size (except on error).
  26.  *
  27.  * Returns NULL or pointer to error.
  28.  */
  29.  
  30. extern os_error *File_LoadTo(char *filename, void *address, int *size )
  31. {
  32.   _kernel_swi_regs r;
  33.   _kernel_oserror  *error;
  34.  
  35.   r.r[0] = 255;
  36.   r.r[1] = (int) filename;
  37.   r.r[2] = (int) address;
  38.   r.r[3] = 0;
  39.  
  40.   error = _kernel_swi( SWI_OS_File, &r, &r );
  41.   
  42.   if (error != NULL)
  43.     return( (os_error *) error );
  44.  
  45.   if (size != NULL)
  46.     *size = r.r[4];
  47.  
  48.   return( NULL );
  49.  
  50. }
  51.